/**
 * 刚刚
 * @param {String} time 待判断的数据 2021-11-26 11:21:02
 * @returns String
 */
function dateDiff(time){       
    var d_minutes,d_hours,d_days,d;
    var nowTime = parseInt(new Date().getTime()/1000);
    newTime = new Date(time).getTime()/1000;
    d = nowTime - newTime;       
    d_days = parseInt(d/86400);       
    d_hours = parseInt(d/3600);       
    d_minutes = parseInt(d/60);    
    if(d_days>0 && d_days<4){       
        return d_days+"天前";       
    }else if(d_days<=0 && d_hours>0){       
        return d_hours+"小时前";       
    }else if(d_hours<=0 && d_minutes>0){       
        return d_minutes+"分钟前";       
    }else{
        return "刚刚";
    }
}

/**
 * 日期格式化
 * @param {String} fuhao 日期间的分隔符 -
 * @returns String
 */
function nowTime(fuhao){
    var date = new Date
    var rs = date.getFullYear()+fuhao+(date.getMonth()+1)+fuhao+date.getDate()+'&nbsp&nbsp'+date.getHours()+':'+date.getMinutes()+':'+date.getSeconds()
    return rs
}

/**
 * 判断浏览器内核
 */
function myBrowser(){
    var browser = navigator.userAgent;
    if(browser.indexOf('Trident') > -1){
        alert('IE内核:trident')
    }
    if(browser.indexOf('Presto') > -1){
        alert('opera内核:presto')
    }
    if(browser.indexOf('AppleWebKit') > -1){
        alert('苹果、谷歌内核:webKit')
    }
    if(browser.indexOf('Firefox') > -1){
        alert('火狐内核:gecko')
    }
}

/**
 * 判断是PC端还是移动端
 * @returns Boolean
 */
function isPC() {  
    var userAgentInfo = navigator.userAgent;  
    var Agents = ['Android','iPhone','SymbianOS','Windows Phone','iPad','iPod' ];  
    var flag = true;  
    for (var i = 0; i < Agents.length; i++) {  
        if (userAgentInfo.indexOf(Agents[i]) != -1) {  
            flag = false;  
            break;  
        }  
    }  
    return flag;  
 }

/**
 * 判断是否是微信浏览器
 */
function isWeixn(){  
    var ua = navigator.userAgent.toLowerCase();  
    if(ua.match(/MicroMessenger/i)=="micromessenger") {  
        alert("是微信浏览器")  
    } else {  
        alert("不是微信浏览器")  
    }  
} 